package com.plian.system.service.pf.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pf.BusinessAudit;
import com.plian.system.mapper.pf.BusinessAuditMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pf.IBusinessAuditService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: Take-off
 * @Description: TODO 经营业绩考核年度 -财务绩效
 * @Date: 2022/12/18 12:07 PM
 * @Version: 1.0
 **/

@Slf4j
@Service
@AllArgsConstructor
public class BusinessAuditServiceImpl extends BaseServiceImpl<BusinessAuditMapper, BusinessAudit> implements IBusinessAuditService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<BusinessAudit> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(BusinessAudit::getBaseBusinessAuditId, ids);
        List<BusinessAudit> BusinessAudits = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(BusinessAudits)){
            return deleteLogic(BusinessAudits.stream().map(BusinessAudit::getId).collect(Collectors.toList()));
        }
        return true;
    }

}
